Skip to content

Conversation

JayWhite2357
Copy link

Rationale

[0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x02] is the encoding of u64::MAX.
This does not return None when decoding even though it should.

This PR fixes this issue.

Changes

  • u64::decode_var now returns None when a 10th byte is used but is more than 1.
  • A test is added for the above case.

@JayWhite2357 JayWhite2357 changed the title fix: decode now returns None with u64::MAX + 1 fix: decode returns None with u64::MAX + 1 Jan 26, 2024
if b & MSB == 0 || shift > (9 * 7) {
success = b & MSB == 0;
if shift > (9 * 7) {
// BUGIFX: this check is required to ensure that we actually return `None` when `src` has a value that would overflow `u64`.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • BUGFIX

@dermesser
Copy link
Owner

thank you for this PR! Would you mind cleaning up the commit history and squashing them into one?

@nyurik
Copy link

nyurik commented Oct 8, 2025

hi, any progress on merging this? Also, @dermesser -- you can simply "squash merge" (there is a dropdown next to the merge button) -- all my projects actually only allow squash-merging to keep the history clean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants